package java_class_work.week07;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * @Auther: admin
 * @Date: 2022/10/24 11:23
 * @Description:
 */

public class JDBCDemo01 {
    public static final String URL = "jdbc:mysql://localhost:3306/blog";
    public static final String USERNAME = "root";
    public static final String PASSWORD = "123456";

    public static void main(String[] args) {
        Connection con = null;
        Statement sta = null;

        try {
            DriverManager.registerDriver(new com.mysql.cj.jdbc.Driver());
            con = DriverManager.getConnection(URL, USERNAME, PASSWORD);
            sta = con.createStatement();
            int i = sta.executeUpdate("update b_user set username = 'root' where id = 2");
            System.out.println("effect rows" + i);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            try {
                sta.close();
                con.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
}
